<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>LIF041-Infographie:  Fichier source de /home/the-king/LIFO41/lifo41-tp-infographie/Camera.h</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript">
$(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Généré par Doxygen 1.7.4 -->
<div id="top">
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td style="padding-left: 0.5em;">
   <div id="projectname">LIF041-Infographie</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Page&#160;principale</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Fichiers</span></a></li>
      <li><a href="dirs.html"><span>Répertoires</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>Liste&#160;des&#160;fichiers</span></a></li>
      <li><a href="globals.html"><span>Membres&#160;de&#160;fichier</span></a></li>
    </ul>
  </div>
</div>
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
  initNavTree('_camera_8h.html','');
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">/home/the-king/LIFO41/lifo41-tp-infographie/Camera.h</div>  </div>
</div>
<div class="contents">
<a href="_camera_8h.html">Aller à la documentation de ce fichier.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="preprocessor">#ifndef CAMERA_H_INCLUDED</span>
<a name="l00002"></a>00002 <span class="preprocessor"></span><span class="preprocessor">#define CAMERA_H_INCLUDED</span>
<a name="l00003"></a>00003 <span class="preprocessor"></span>
<a name="l00004"></a>00004 <span class="preprocessor">#include &quot;<a class="code" href="_vec3f_8h.html">Vec3f.h</a>&quot;</span>
<a name="l00005"></a>00005 
<a name="l00006"></a><a class="code" href="_camera_8h.html#ae81b31bb7a62f93c5e65c8677e1571e3a9832a4ce720e1bed4a2cdfac7d099d64">00006</a> <span class="keyword">enum</span> <a class="code" href="_camera_8h.html#ae81b31bb7a62f93c5e65c8677e1571e3">Camera_FlyTrackball</a> { <a class="code" href="_camera_8h.html#ae81b31bb7a62f93c5e65c8677e1571e3aab640808376391dfcab7f172d716fce7">CAMERA_FLY</a>=0, <a class="code" href="_camera_8h.html#ae81b31bb7a62f93c5e65c8677e1571e3a9832a4ce720e1bed4a2cdfac7d099d64">CAMERA_TRACKBALL</a>=1 };
<a name="l00007"></a>00007 
<a name="l00009"></a><a class="code" href="struct_camera.html">00009</a> <span class="keyword">struct </span><a class="code" href="struct_camera.html" title="A camera is defined by a position and 2 angles of rotations (defining the orientation)">Camera</a>
<a name="l00010"></a>00010 {
<a name="l00011"></a><a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">00011</a>     <a class="code" href="struct_vec3f.html" title="A vector is defined by 3 coord (X,Y,Z)">Vec3f</a> <a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>;
<a name="l00012"></a><a class="code" href="struct_camera.html#ac57d1defa445dd3814fe152297de5420">00012</a>     <span class="keywordtype">float</span> <a class="code" href="struct_camera.html#ac57d1defa445dd3814fe152297de5420">rotLeft</a>;
<a name="l00013"></a><a class="code" href="struct_camera.html#a9fb5412919bf0f15368be9144a78845d">00013</a>     <span class="keywordtype">float</span> <a class="code" href="struct_camera.html#a9fb5412919bf0f15368be9144a78845d">rotUp</a>;
<a name="l00014"></a><a class="code" href="struct_camera.html#a5cd3d313b4870adbaa4dd2eac63be842">00014</a>     <span class="keywordtype">int</span> <a class="code" href="struct_camera.html#a5cd3d313b4870adbaa4dd2eac63be842">mode</a>;       <span class="comment">// 0=neutral, 1=rotation mode, 2=translation mode</span>
<a name="l00015"></a><a class="code" href="struct_camera.html#a2bb20741a5b38d263e265e1f4626c4ea">00015</a>     <a class="code" href="_camera_8h.html#ae81b31bb7a62f93c5e65c8677e1571e3">Camera_FlyTrackball</a> <a class="code" href="struct_camera.html#a2bb20741a5b38d263e265e1f4626c4ea">flyOrTrackball</a>;
<a name="l00016"></a><a class="code" href="struct_camera.html#a4a197430101d1f40bbf49555f1872b05">00016</a>     <span class="keywordtype">int</span> <a class="code" href="struct_camera.html#ae7fd0a6e3298ff5c054f0769160e57cc">mx</a>,<a class="code" href="struct_camera.html#a4a197430101d1f40bbf49555f1872b05">my</a>;      <span class="comment">// mouse position</span>
<a name="l00017"></a>00017 };
<a name="l00018"></a>00018 
<a name="l00019"></a>00019 
<a name="l00020"></a><a class="code" href="_camera_8h.html#a206a19955e773f77b6adde99cf050882">00020</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="_camera_8h.html#a206a19955e773f77b6adde99cf050882">camInit</a>(<a class="code" href="struct_camera.html" title="A camera is defined by a position and 2 angles of rotations (defining the orientation)">Camera</a>&amp; <a class="code" href="opengl_8cpp.html#a3b23650c3f80b53cee3a2c471797c732">cam</a>, <span class="keyword">const</span> <a class="code" href="_camera_8h.html#ae81b31bb7a62f93c5e65c8677e1571e3">Camera_FlyTrackball</a> ft=<a class="code" href="_camera_8h.html#ae81b31bb7a62f93c5e65c8677e1571e3a9832a4ce720e1bed4a2cdfac7d099d64">CAMERA_TRACKBALL</a>)
<a name="l00021"></a>00021 {
<a name="l00022"></a>00022     cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>.<a class="code" href="struct_vec3f.html#a4ee774446db3cafa0f9682065a64ba32">x</a> = 0;
<a name="l00023"></a>00023     cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>.<a class="code" href="struct_vec3f.html#a3b01268bf88a45f95a45097b0457393f">y</a> = 2;
<a name="l00024"></a>00024     cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>.<a class="code" href="struct_vec3f.html#a78f2ea154cc9996ad95397a1fb0f4033">z</a> = 10;
<a name="l00025"></a>00025     cam.<a class="code" href="struct_camera.html#a9fb5412919bf0f15368be9144a78845d">rotUp</a> = 0;
<a name="l00026"></a>00026     cam.<a class="code" href="struct_camera.html#ac57d1defa445dd3814fe152297de5420">rotLeft</a> = 0;
<a name="l00027"></a>00027     cam.<a class="code" href="struct_camera.html#a5cd3d313b4870adbaa4dd2eac63be842">mode</a> = 0;
<a name="l00028"></a>00028     cam.<a class="code" href="struct_camera.html#a2bb20741a5b38d263e265e1f4626c4ea">flyOrTrackball</a> = ft;
<a name="l00029"></a>00029 
<a name="l00030"></a>00030 }
<a name="l00031"></a>00031 
<a name="l00032"></a>00032 
<a name="l00033"></a><a class="code" href="_camera_8h.html#a2752f3a061dc5963c7ace66ef8514150">00033</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="_camera_8h.html#a2752f3a061dc5963c7ace66ef8514150">camComputeDirFront</a>( <span class="keyword">const</span> <a class="code" href="struct_camera.html" title="A camera is defined by a position and 2 angles of rotations (defining the orientation)">Camera</a>&amp; <a class="code" href="opengl_8cpp.html#a3b23650c3f80b53cee3a2c471797c732">cam</a>, <a class="code" href="struct_vec3f.html" title="A vector is defined by 3 coord (X,Y,Z)">Vec3f</a>&amp; dir)
<a name="l00034"></a>00034 {
<a name="l00035"></a>00035     <span class="keywordflow">if</span> (cam.<a class="code" href="struct_camera.html#a2bb20741a5b38d263e265e1f4626c4ea">flyOrTrackball</a>==<a class="code" href="_camera_8h.html#ae81b31bb7a62f93c5e65c8677e1571e3aab640808376391dfcab7f172d716fce7">CAMERA_FLY</a>)
<a name="l00036"></a>00036     {
<a name="l00037"></a>00037         <span class="keywordtype">float</span> a = <a class="code" href="_vec3f_8cpp.html#abbcf5b5ffcc3a0891c1fc9d8a864d56d" title="degree -&gt; radian">rad</a>(cam.<a class="code" href="struct_camera.html#a9fb5412919bf0f15368be9144a78845d">rotUp</a>);
<a name="l00038"></a>00038         <span class="keywordtype">float</span> b = <a class="code" href="_vec3f_8cpp.html#abbcf5b5ffcc3a0891c1fc9d8a864d56d" title="degree -&gt; radian">rad</a>(cam.<a class="code" href="struct_camera.html#ac57d1defa445dd3814fe152297de5420">rotLeft</a>);
<a name="l00039"></a>00039         <span class="keywordtype">int</span> signz=(cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>.<a class="code" href="struct_vec3f.html#a78f2ea154cc9996ad95397a1fb0f4033">z</a>&gt;0)?1:-1;
<a name="l00040"></a>00040         <span class="keywordtype">int</span> signy=(cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>.<a class="code" href="struct_vec3f.html#a3b01268bf88a45f95a45097b0457393f">y</a>&gt;0)?1:-1;
<a name="l00041"></a>00041         <a class="code" href="_vec3f_8cpp.html#a54ed0dadd24fcc09a03cd706e3b5140d" title="v=(x,y,z)">vecInit</a>( dir, sin(b), -signz*signy*sin(a)*cos(b), -cos(a)*cos(b));
<a name="l00042"></a>00042     }
<a name="l00043"></a>00043     <span class="keywordflow">else</span>
<a name="l00044"></a>00044     {
<a name="l00045"></a>00045         <a class="code" href="_vec3f_8cpp.html#a54ed0dadd24fcc09a03cd706e3b5140d" title="v=(x,y,z)">vecInit</a>( dir, -cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>.<a class="code" href="struct_vec3f.html#a4ee774446db3cafa0f9682065a64ba32">x</a>, -cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>.<a class="code" href="struct_vec3f.html#a3b01268bf88a45f95a45097b0457393f">y</a>, -cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>.<a class="code" href="struct_vec3f.html#a78f2ea154cc9996ad95397a1fb0f4033">z</a>);
<a name="l00046"></a>00046         <a class="code" href="_vec3f_8cpp.html#a1c94f47fef6168c9a27f4a2ce3d78394" title="normalize the vector">vecNormalize</a>( dir );
<a name="l00047"></a>00047     }
<a name="l00048"></a>00048 <span class="comment">//    glMatrixMode(GL_MODELVIEW);</span>
<a name="l00049"></a>00049 <span class="comment">//    glPushMatrix();</span>
<a name="l00050"></a>00050 <span class="comment">//    camSetGL( cam );</span>
<a name="l00051"></a>00051 <span class="comment">//    float m[16];</span>
<a name="l00052"></a>00052 <span class="comment">//    glGetFloatv( GL_MODELVIEW_MATRIX, m);</span>
<a name="l00053"></a>00053 <span class="comment">//    vecInit( dir, m[2], m[6], m[10]);</span>
<a name="l00054"></a>00054 <span class="comment">//    glPopMatrix();</span>
<a name="l00055"></a>00055 
<a name="l00056"></a>00056 }
<a name="l00057"></a>00057 
<a name="l00058"></a><a class="code" href="_camera_8h.html#a0c2ffedc8529ec20b7ece7f76c7423e5">00058</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="_camera_8h.html#a0c2ffedc8529ec20b7ece7f76c7423e5">camSetFlyTrackballMode</a>(<a class="code" href="struct_camera.html" title="A camera is defined by a position and 2 angles of rotations (defining the orientation)">Camera</a>&amp; <a class="code" href="opengl_8cpp.html#a3b23650c3f80b53cee3a2c471797c732">cam</a>, <span class="keyword">const</span> <a class="code" href="_camera_8h.html#ae81b31bb7a62f93c5e65c8677e1571e3">Camera_FlyTrackball</a> m)
<a name="l00059"></a>00059 {
<a name="l00060"></a>00060 <span class="comment">//    cam.flyOrTrackball = m;</span>
<a name="l00061"></a>00061     <a class="code" href="_camera_8h.html#a206a19955e773f77b6adde99cf050882">camInit</a>( cam, m);
<a name="l00062"></a>00062 }
<a name="l00063"></a>00063 
<a name="l00064"></a><a class="code" href="_camera_8h.html#aab591e60d2af091aed8880d3d2892f55">00064</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="_camera_8h.html#aab591e60d2af091aed8880d3d2892f55">camSetGL</a>(<span class="keyword">const</span> <a class="code" href="struct_camera.html" title="A camera is defined by a position and 2 angles of rotations (defining the orientation)">Camera</a>&amp; <a class="code" href="opengl_8cpp.html#a3b23650c3f80b53cee3a2c471797c732">cam</a>)
<a name="l00065"></a>00065 {
<a name="l00066"></a>00066 
<a name="l00067"></a>00067 <span class="comment">//Vec3f dir;</span>
<a name="l00068"></a>00068 <span class="comment">//camComputeDirFront(cam, dir);</span>
<a name="l00069"></a>00069 <span class="comment">//vecPrint(dir);</span>
<a name="l00070"></a>00070 <span class="comment">//printf(&quot;%f %f\n\n&quot;, cam.rotUp, cam.rotLeft);</span>
<a name="l00071"></a>00071 
<a name="l00072"></a>00072     glMatrixMode( GL_MODELVIEW);
<a name="l00073"></a>00073 
<a name="l00074"></a>00074     <span class="keywordflow">if</span> (cam.<a class="code" href="struct_camera.html#a2bb20741a5b38d263e265e1f4626c4ea">flyOrTrackball</a>==<a class="code" href="_camera_8h.html#ae81b31bb7a62f93c5e65c8677e1571e3aab640808376391dfcab7f172d716fce7">CAMERA_FLY</a>)
<a name="l00075"></a>00075     {
<a name="l00076"></a>00076         glRotatef( cam.<a class="code" href="struct_camera.html#a9fb5412919bf0f15368be9144a78845d">rotUp</a>, 1.0f, 0, 0);
<a name="l00077"></a>00077         glRotatef( cam.<a class="code" href="struct_camera.html#ac57d1defa445dd3814fe152297de5420">rotLeft</a>, 0, 1.0f, 0);
<a name="l00078"></a>00078         glTranslatef( -cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>.<a class="code" href="struct_vec3f.html#a4ee774446db3cafa0f9682065a64ba32">x</a>, -cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>.<a class="code" href="struct_vec3f.html#a3b01268bf88a45f95a45097b0457393f">y</a>, -cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>.<a class="code" href="struct_vec3f.html#a78f2ea154cc9996ad95397a1fb0f4033">z</a>);
<a name="l00079"></a>00079     }
<a name="l00080"></a>00080     <span class="keywordflow">else</span>
<a name="l00081"></a>00081     {
<a name="l00082"></a>00082         glTranslatef( -cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>.<a class="code" href="struct_vec3f.html#a4ee774446db3cafa0f9682065a64ba32">x</a>, -cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>.<a class="code" href="struct_vec3f.html#a3b01268bf88a45f95a45097b0457393f">y</a>, -cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>.<a class="code" href="struct_vec3f.html#a78f2ea154cc9996ad95397a1fb0f4033">z</a>);
<a name="l00083"></a>00083         glRotatef( cam.<a class="code" href="struct_camera.html#a9fb5412919bf0f15368be9144a78845d">rotUp</a>, 1.0f, 0, 0);
<a name="l00084"></a>00084         glRotatef( cam.<a class="code" href="struct_camera.html#ac57d1defa445dd3814fe152297de5420">rotLeft</a>, 0, 1.0f, 0);
<a name="l00085"></a>00085     }
<a name="l00086"></a>00086 }
<a name="l00087"></a>00087 
<a name="l00088"></a><a class="code" href="_camera_8h.html#abbae455caebd8596c16bdfb32423fe0b">00088</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="_camera_8h.html#abbae455caebd8596c16bdfb32423fe0b">camTurnUpDown</a>(<a class="code" href="struct_camera.html" title="A camera is defined by a position and 2 angles of rotations (defining the orientation)">Camera</a>&amp; <a class="code" href="opengl_8cpp.html#a3b23650c3f80b53cee3a2c471797c732">cam</a>, <span class="keyword">const</span> <span class="keywordtype">float</span> stepR=2.f)
<a name="l00089"></a>00089 {
<a name="l00090"></a>00090     cam.<a class="code" href="struct_camera.html#a9fb5412919bf0f15368be9144a78845d">rotUp</a> += stepR;
<a name="l00091"></a>00091 }
<a name="l00092"></a><a class="code" href="_camera_8h.html#a3c9cef1616ec20ebae9496508ea90d69">00092</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="_camera_8h.html#a3c9cef1616ec20ebae9496508ea90d69">camTurnLeftRight</a>(<a class="code" href="struct_camera.html" title="A camera is defined by a position and 2 angles of rotations (defining the orientation)">Camera</a>&amp; <a class="code" href="opengl_8cpp.html#a3b23650c3f80b53cee3a2c471797c732">cam</a>, <span class="keyword">const</span> <span class="keywordtype">float</span> stepR=2.f)
<a name="l00093"></a>00093 {
<a name="l00094"></a>00094     cam.<a class="code" href="struct_camera.html#ac57d1defa445dd3814fe152297de5420">rotLeft</a> += stepR;
<a name="l00095"></a>00095 }
<a name="l00096"></a>00096 
<a name="l00097"></a>00097 
<a name="l00098"></a><a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786daba595d8bca8bc5e67c37c0a9d89becfa">00098</a> <span class="keyword">enum</span> <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786d">DIR</a> { <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786da76bd5ec6ea9d8a1b582d8d5e43102a02">FRONT</a>, <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786dac921ff2cfc571c1d19b0485d7f6926ee">BACK</a>, <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786dadb45120aafd37a973140edee24708065">LEFT</a>, <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786daec8379af7490bb9eaaf579cf17876f38">RIGHT</a>, <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786daba595d8bca8bc5e67c37c0a9d89becfa">UP</a>, <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786da9b0b4a95b99523966e0e34ffdadac9da">DOWN</a> };
<a name="l00099"></a><a class="code" href="_camera_8h.html#a3562de3314274820a3f25e03ee9a3595">00099</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="_camera_8h.html#a3562de3314274820a3f25e03ee9a3595">camTranslate</a>(<a class="code" href="struct_camera.html" title="A camera is defined by a position and 2 angles of rotations (defining the orientation)">Camera</a>&amp; <a class="code" href="opengl_8cpp.html#a3b23650c3f80b53cee3a2c471797c732">cam</a>, <span class="keyword">const</span> <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786d">DIR</a> where, <span class="keyword">const</span> <span class="keywordtype">float</span> c=1.f)
<a name="l00100"></a>00100 {
<a name="l00101"></a>00101     <a class="code" href="struct_vec3f.html" title="A vector is defined by 3 coord (X,Y,Z)">Vec3f</a> dir, up, right;
<a name="l00102"></a>00102 
<a name="l00103"></a>00103     <a class="code" href="_camera_8h.html#a2752f3a061dc5963c7ace66ef8514150">camComputeDirFront</a>( cam, dir);
<a name="l00104"></a>00104 
<a name="l00105"></a>00105     <span class="comment">//vecInit( dir, a, b);</span>
<a name="l00106"></a>00106     <span class="keywordflow">if</span> (dir.<a class="code" href="struct_vec3f.html#a3b01268bf88a45f95a45097b0457393f">y</a>&gt;=1.f)
<a name="l00107"></a>00107         <a class="code" href="_vec3f_8cpp.html#a54ed0dadd24fcc09a03cd706e3b5140d" title="v=(x,y,z)">vecInit</a>( up, 1, 0, 0);
<a name="l00108"></a>00108     <span class="keywordflow">else</span>
<a name="l00109"></a>00109         <a class="code" href="_vec3f_8cpp.html#a54ed0dadd24fcc09a03cd706e3b5140d" title="v=(x,y,z)">vecInit</a>( up, 0, 1, 0);
<a name="l00110"></a>00110     <a class="code" href="_vec3f_8cpp.html#a66d8205538c53312775745ff729de541" title="Cross product (produit vectoriel)">vecCross</a>( right, dir, up );
<a name="l00111"></a>00111 
<a name="l00112"></a>00112     <a class="code" href="struct_vec3f.html" title="A vector is defined by 3 coord (X,Y,Z)">Vec3f</a> tr, res;
<a name="l00113"></a>00113     <a class="code" href="_vec3f_8cpp.html#a54ed0dadd24fcc09a03cd706e3b5140d" title="v=(x,y,z)">vecInit</a>( tr, 0,0,0);
<a name="l00114"></a>00114     <span class="keywordflow">switch</span> (where)
<a name="l00115"></a>00115     {
<a name="l00116"></a>00116     <span class="keywordflow">case</span> <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786daba595d8bca8bc5e67c37c0a9d89becfa">UP</a>:
<a name="l00117"></a>00117         <a class="code" href="_vec3f_8cpp.html#abe76b44875ddd84236caacc0d016e20a" title="R = a*B.">vecMul</a>( tr, c, up);
<a name="l00118"></a>00118         <span class="keywordflow">break</span>;
<a name="l00119"></a>00119 
<a name="l00120"></a>00120     <span class="keywordflow">case</span> <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786da9b0b4a95b99523966e0e34ffdadac9da">DOWN</a>:
<a name="l00121"></a>00121         <a class="code" href="_vec3f_8cpp.html#abe76b44875ddd84236caacc0d016e20a" title="R = a*B.">vecMul</a>( tr, -c, up);
<a name="l00122"></a>00122         <span class="keywordflow">break</span>;
<a name="l00123"></a>00123 
<a name="l00124"></a>00124     <span class="keywordflow">case</span> <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786da76bd5ec6ea9d8a1b582d8d5e43102a02">FRONT</a>:
<a name="l00125"></a>00125         <a class="code" href="_vec3f_8cpp.html#abe76b44875ddd84236caacc0d016e20a" title="R = a*B.">vecMul</a>( tr, c, dir);
<a name="l00126"></a>00126         <span class="keywordflow">break</span>;
<a name="l00127"></a>00127 
<a name="l00128"></a>00128     <span class="keywordflow">case</span> <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786dac921ff2cfc571c1d19b0485d7f6926ee">BACK</a>:
<a name="l00129"></a>00129         <a class="code" href="_vec3f_8cpp.html#abe76b44875ddd84236caacc0d016e20a" title="R = a*B.">vecMul</a>( tr, -c, dir);
<a name="l00130"></a>00130         <span class="keywordflow">break</span>;
<a name="l00131"></a>00131 
<a name="l00132"></a>00132     <span class="keywordflow">case</span> <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786dadb45120aafd37a973140edee24708065">LEFT</a>:
<a name="l00133"></a>00133         <a class="code" href="_vec3f_8cpp.html#abe76b44875ddd84236caacc0d016e20a" title="R = a*B.">vecMul</a>( tr, -c, right);
<a name="l00134"></a>00134         <span class="keywordflow">break</span>;
<a name="l00135"></a>00135 
<a name="l00136"></a>00136     <span class="keywordflow">case</span> <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786daec8379af7490bb9eaaf579cf17876f38">RIGHT</a>:
<a name="l00137"></a>00137         <a class="code" href="_vec3f_8cpp.html#abe76b44875ddd84236caacc0d016e20a" title="R = a*B.">vecMul</a>( tr, c, right);
<a name="l00138"></a>00138         <span class="keywordflow">break</span>;
<a name="l00139"></a>00139     }
<a name="l00140"></a>00140     <span class="comment">//printf(&quot;%f %f %f\n&quot;, cam.pos.x, cam.pos.y, cam.pos.z);</span>
<a name="l00141"></a>00141     <a class="code" href="_vec3f_8cpp.html#a4d22258d1021383e38583a2a69ed1843" title="R=A+B.">vecAdd</a>( res, cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>, tr);
<a name="l00142"></a>00142     <span class="keywordflow">if</span> (<a class="code" href="_vec3f_8cpp.html#ac64a94c5bb8b6324dbd629cb1f13c95a" title="return the length of the vector">vecLength</a>(res)&gt;1.f) cam.<a class="code" href="struct_camera.html#aaa7eaab22236f016fd933666bd90c741">pos</a>=res;
<a name="l00143"></a>00143 }
<a name="l00144"></a>00144 
<a name="l00145"></a><a class="code" href="_camera_8h.html#ac4b5690f4eeff9e93cedfa2c72a2d9cea3b27179d16d00292c38c69b95629438b">00145</a> <span class="keyword">enum</span> <a class="code" href="_camera_8h.html#ac4b5690f4eeff9e93cedfa2c72a2d9ce">CAMERA_MODE</a> { <a class="code" href="_camera_8h.html#ac4b5690f4eeff9e93cedfa2c72a2d9cea6f86769678297fbf3cc4742a8bce4b08">CAMERA_STOP</a>, <a class="code" href="_camera_8h.html#ac4b5690f4eeff9e93cedfa2c72a2d9ceaa773dfd7b41128024e2c03690daa3fe4">CAMERA_ROTATION</a>, <a class="code" href="_camera_8h.html#ac4b5690f4eeff9e93cedfa2c72a2d9cea3b27179d16d00292c38c69b95629438b">CAMERA_TRANSLATION</a> };
<a name="l00146"></a><a class="code" href="_camera_8h.html#a9952be394a8f5e167969016ea228047e">00146</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="_camera_8h.html#a9952be394a8f5e167969016ea228047e">camStartMove</a>( <a class="code" href="struct_camera.html" title="A camera is defined by a position and 2 angles of rotations (defining the orientation)">Camera</a>&amp; <a class="code" href="opengl_8cpp.html#a3b23650c3f80b53cee3a2c471797c732">cam</a>, <span class="keyword">const</span> <a class="code" href="_camera_8h.html#ac4b5690f4eeff9e93cedfa2c72a2d9ce">CAMERA_MODE</a> mode, <span class="keyword">const</span> <span class="keywordtype">int</span> x, <span class="keyword">const</span> <span class="keywordtype">int</span> y)
<a name="l00147"></a>00147 {
<a name="l00148"></a>00148     cam.<a class="code" href="struct_camera.html#a5cd3d313b4870adbaa4dd2eac63be842">mode</a> = mode;
<a name="l00149"></a>00149     cam.<a class="code" href="struct_camera.html#ae7fd0a6e3298ff5c054f0769160e57cc">mx</a> = x;
<a name="l00150"></a>00150     cam.<a class="code" href="struct_camera.html#a4a197430101d1f40bbf49555f1872b05">my</a> = y;
<a name="l00151"></a>00151 }
<a name="l00152"></a>00152 
<a name="l00153"></a><a class="code" href="_camera_8h.html#aa3f52e75bb54fd6415396885c771affa">00153</a> <span class="keyword">inline</span> <span class="keywordtype">void</span> <a class="code" href="_camera_8h.html#aa3f52e75bb54fd6415396885c771affa">camMove</a>( <a class="code" href="struct_camera.html" title="A camera is defined by a position and 2 angles of rotations (defining the orientation)">Camera</a>&amp; <a class="code" href="opengl_8cpp.html#a3b23650c3f80b53cee3a2c471797c732">cam</a>, <span class="keyword">const</span> <span class="keywordtype">int</span> x, <span class="keyword">const</span> <span class="keywordtype">int</span> y)
<a name="l00154"></a>00154 {
<a name="l00155"></a>00155     <span class="keywordflow">if</span> (cam.<a class="code" href="struct_camera.html#a5cd3d313b4870adbaa4dd2eac63be842">mode</a>==<a class="code" href="_camera_8h.html#ac4b5690f4eeff9e93cedfa2c72a2d9cea3b27179d16d00292c38c69b95629438b">CAMERA_TRANSLATION</a>)
<a name="l00156"></a>00156     {
<a name="l00157"></a>00157         <span class="keywordflow">if</span> (y&gt;cam.<a class="code" href="struct_camera.html#a4a197430101d1f40bbf49555f1872b05">my</a>) <a class="code" href="_camera_8h.html#a3562de3314274820a3f25e03ee9a3595">camTranslate</a>( cam, <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786dac921ff2cfc571c1d19b0485d7f6926ee">BACK</a>);
<a name="l00158"></a>00158         <span class="keywordflow">else</span> <a class="code" href="_camera_8h.html#a3562de3314274820a3f25e03ee9a3595">camTranslate</a>( cam, <a class="code" href="_camera_8h.html#a49eb6ac4643553d04b85c70646c6786da76bd5ec6ea9d8a1b582d8d5e43102a02">FRONT</a>);
<a name="l00159"></a>00159     }
<a name="l00160"></a>00160     <span class="keywordflow">else</span> <span class="keywordflow">if</span> (cam.<a class="code" href="struct_camera.html#a5cd3d313b4870adbaa4dd2eac63be842">mode</a>==<a class="code" href="_camera_8h.html#ac4b5690f4eeff9e93cedfa2c72a2d9ceaa773dfd7b41128024e2c03690daa3fe4">CAMERA_ROTATION</a>)
<a name="l00161"></a>00161     {
<a name="l00162"></a>00162 <span class="comment">//        if (abs(y-cam.my)&gt;3)</span>
<a name="l00163"></a>00163         <a class="code" href="_camera_8h.html#abbae455caebd8596c16bdfb32423fe0b">camTurnUpDown</a>( cam, 0.5f*(y-cam.<a class="code" href="struct_camera.html#a4a197430101d1f40bbf49555f1872b05">my</a>));
<a name="l00164"></a>00164 <span class="comment">//        if (abs(x-cam.mx)&gt;3)</span>
<a name="l00165"></a>00165         <a class="code" href="_camera_8h.html#a3c9cef1616ec20ebae9496508ea90d69">camTurnLeftRight</a>( cam, 0.5f*(x-cam.<a class="code" href="struct_camera.html#ae7fd0a6e3298ff5c054f0769160e57cc">mx</a>));
<a name="l00166"></a>00166     }
<a name="l00167"></a>00167     cam.<a class="code" href="struct_camera.html#ae7fd0a6e3298ff5c054f0769160e57cc">mx</a> = x;
<a name="l00168"></a>00168     cam.<a class="code" href="struct_camera.html#a4a197430101d1f40bbf49555f1872b05">my</a> = y;
<a name="l00169"></a>00169 }
<a name="l00170"></a>00170 
<a name="l00171"></a>00171 
<a name="l00172"></a>00172 <span class="preprocessor">#endif // CAMERA_H_INCLUDED</span>
</pre></div></div>
</div>
  <div id="nav-path" class="navpath">
    <ul>
      <li class="navelem"><a class="el" href="_camera_8h.html">Camera.h</a>      </li>
      <li class="footer">Généré le Tue Jan 3 2012 09:33:59 pour LIF041-Infographie par&#160;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </li>
    </ul>
  </div>

</body>
</html>
